﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text;
using System.Collections;

namespace MapServer
{
    public class SetSession: System.Web.UI.Page
    {
        public static ArrayList aLatLon = new ArrayList();
        public void SetUserName( String sUserName )
        {
             Session["UserName"] = sUserName;
        }
        public String GetUserName()
        {
            String sUserName = String.Empty;
            if (Session["UserName"] != null)
            {
                sUserName = Session["UserName"].ToString();
            }
            return sUserName;
        }
        public void SetName(String sName)
        {
            Session["Name"] = sName;
        }
        public String GetName()
        {
            String sName = String.Empty;
            if (Session["Name"] != null)
            {
                sName = Session["Name"].ToString();
            }
            return sName;
        }
        public void SetUserId(int iUserId)
        {
            Session["UserId"] = iUserId;
        }
        public int GetUserId()
        {
            int iUserId = -1;
            if (Session["UserId"] != null)
            {
                iUserId = Convert.ToInt32( Session["UserId"]);
            }
            return iUserId;
        }
        public void SetUserType( int iType)
        {
            Session["UserType"] = iType; 
        }
        public int GetUserType()
        {
            int iUserType = -1;
            if (Session["UserType"] != null)
            {
                iUserType = Convert.ToInt32(Session["UserType"]);
            }
            return iUserType;
        }
        public void SetCheId(int iCheId)
        {
            Session["CheId"] = iCheId;
        }
        public int GetCheId()
        {
            int iCheId = -1;
            if ( Session["CheId"] != null )
            {
                iCheId = Convert.ToInt32(Session["CheId"]);
            }
            return iCheId;
        }
        public void SetServerType(int iServerType)
        {
            Session["ServerType"] = iServerType;
        }
        public int GetServerType()
        {
            int iServerType = -1;
            if (Session["ServerType"] != null)
            {
                iServerType = Convert.ToInt32( Session["ServerType"] );
            }
            return iServerType;
        }
        public void SetLatLon(WebSocket.STRU_GPS_DATA_PASS sLatLon)
        {
            Session["LatLon"] = sLatLon;
        }
        public ArrayList GetLatLon()
        {
            ArrayList sLatLon = null;
            if (Session["LatLon"]!=null)
            {
                sLatLon = (ArrayList)Session["LatLon"];
            }
            return sLatLon;
        }
        public void SetChe(DataTable dDt)
        {
            Session["Che"] = dDt;
        }
        public DataTable GetChe()
        {
            DataTable dDt = null;
            if (Session["Che"] != null)
            {
                dDt = (DataTable)Session["Che"];
            }
            return dDt;
        }
        public String SelectChePaiHao(int iId)
        {
            String sChePaiHao = String.Empty;
            DataTable dDt = GetChe();

            for (int i = 0; i < dDt.Rows.Count; i++)
            {
                if (Convert.ToInt32(dDt.Rows[i]["id"]) == iId)
                {
                    sChePaiHao = dDt.Rows[i]["chePaiHaoMa"].ToString().Trim();
                    break;
                }
            }
            return sChePaiHao;
        }
        public void ShowMessage( String sMessage,int iFlag )
        {
            StringBuilder sCmdText = new StringBuilder();
            if (sMessage == null)
            {
                return;
            }
            if (sMessage == String.Empty)
            {
                return;
            }
            if (iFlag == 0)
            {
                sMessage = "系统提示:"+sMessage;
            } 
            
            sCmdText.Append("<script language=\"javascript\"> \n");
            sCmdText.Append("alert(\"" + sMessage.Trim() + "\"); \n");
            sCmdText.Append("</script>");

            System.Web.HttpContext.Current.Response.Write(sCmdText.ToString());
        }
        public void Location( String sUrl )
        {
            if (sUrl == null)
            {
                return;
            }
            if (sUrl == String.Empty)
            {
                return;
            }
            System.Web.HttpContext.Current.Response.Write("<script>window.location='" + sUrl + "';</script>");   
        }
    }
}
